const mixin = {
  data() {
    return {
      tableHeight: 0,
    };
  },
  beforeCreate() {
    this.$nextTick(() => {
      window.addEventListener("resize", this.updateTableHeight);
      setTimeout(() => {
        this.updateTableHeight();
      }, 600);
    });
  },

  methods: {
    updateTableHeight() {
      this.tableHeight = 0;
      this.$nextTick(() => {
        const table = document.querySelector("#el-table");
        const offsetTop = table ? table.offsetTop : 0;
        const windowHeight = window.innerHeight;
        const header = 50,
          tagsView = 0,
          padding = 40;
        const height = windowHeight - offsetTop - padding;
        if (height < 300) {
          this.tableHeight = 300 + "";
        } else {
          this.tableHeight = height;
        }
      });
    },
  },
  beforeDestroy() {
    window.removeEventListener("resize", this.updateTableHeight);
  },
};
export { mixin };
